Merge branch 'master' into scenarios

Conflicts:
app/assets/stylesheets/application.css.scss.erb
app/views/agents/index.html.erb
app/views/agents/show.html.erb

Andrew Cantino 10 years ago
parent
commit
32ef369503

+ 16 - 5
app/assets/stylesheets/application.css.scss.erb

@@ -136,10 +136,8 @@ span.not-applicable:after {
136 136
 
137 137
 // Disabled
138 138
 
139
-tr.agent-disabled {
140
-  td {
141
-    opacity: 0.5;
142
-  }
139
+.agent-disabled {
140
+  opacity: 0.5;
143 141
 }
144 142
 
145 143
 // Fix JSON Editor
@@ -157,4 +155,17 @@ tr.agent-disabled {
157 155
 h2 .scenario {
158 156
   position: relative;
159 157
   top: -2px;
160
-}
158
+}
159
+
160
+// Bootstrappy color styles
161
+.color-danger {
162
+  color: #d9534f;
163
+}
164
+
165
+.color-warning {
166
+  color: #f0ad4e;
167
+}
168
+
169
+.color-success {
170
+  color: #5cb85c;
171
+}

+ 2 - 2
app/helpers/application_helper.rb

@@ -9,11 +9,11 @@ module ApplicationHelper
9 9
 
10 10
   def working(agent)
11 11
     if agent.disabled?
12
-      '<span class="label label-warning">Disabled</span>'.html_safe
12
+      link_to '<span class="label label-warning">Disabled</span>'.html_safe, agent_path(agent)
13 13
     elsif agent.working?
14 14
       '<span class="label label-success">Yes</span>'.html_safe
15 15
     else
16
-      link_to '<span class="label btn-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
16
+      link_to '<span class="label label-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
17 17
     end
18 18
   end
19 19
 end

+ 1 - 1
app/models/agents/imap_folder_agent.rb

@@ -372,7 +372,7 @@ module Agents
372 372
           imap = new(host, port, ssl)
373 373
           yield imap
374 374
         ensure
375
-          imap.disconnect
375
+          imap.disconnect unless imap.nil?
376 376
         end
377 377
       end
378 378
 

+ 41 - 0
app/views/agents/_action_menu.html.erb

@@ -0,0 +1,41 @@
1
+<ul class="dropdown-menu" role="menu">
2
+  <% if agent.can_be_scheduled? %>
3
+    <li>
4
+      <%= link_to '<span class="color-success glyphicon glyphicon-refresh"></span> Run'.html_safe, run_agent_path(agent, :return => returnTo), method: :post, :tabindex => "-1" %>
5
+    </li>
6
+  <% end %>
7
+
8
+  <li>
9
+    <%= link_to '<span class="glyphicon glyphicon-eye-open"></span> Show'.html_safe, agent_path(agent) %>
10
+  </li>
11
+
12
+  <li class="divider"></li>
13
+
14
+  <li>
15
+    <%= link_to '<span class="glyphicon glyphicon-pencil"></span> Edit agent'.html_safe, edit_agent_path(agent) %>
16
+  </li>
17
+
18
+  <li>
19
+    <%= link_to '<span class="glyphicon glyphicon-plus"></span> Clone agent'.html_safe, new_agent_path(id: agent), :tabindex => "-1" %>
20
+  </li>
21
+
22
+  <li>
23
+    <% if agent.disabled? %>
24
+      <%= link_to '<i class="glyphicon glyphicon-play"></i> Enable agent'.html_safe, agent_path(agent, :agent => { :disabled => false }, :return => returnTo), :method => :put %>
25
+    <% else %>
26
+      <%= link_to '<i class="glyphicon glyphicon-pause"></i> Disable agent'.html_safe, agent_path(agent, :agent => { :disabled => true }, :return => returnTo), :method => :put %>
27
+    <% end %>
28
+  </li>
29
+
30
+  <li class="divider"></li>
31
+
32
+  <% if agent.can_create_events? && agent.events.count > 0 %>
33
+    <li>
34
+      <%= link_to '<span class="color-danger glyphicon glyphicon-trash"></span> Delete all events'.html_safe, remove_events_agent_path(agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL emitted events for this Agent?'}, :tabindex => "-1" %>
35
+    </li>
36
+  <% end %>
37
+
38
+  <li>
39
+    <%= link_to '<span class="color-danger glyphicon glyphicon-remove"></span> Delete agent'.html_safe, agent_path(agent), method: :delete, data: { confirm: 'Are you sure that you want to permanently delete this Agent?' }, :tabindex => "-1" %>
40
+  </li>
41
+</ul>

+ 14 - 18
app/views/agents/_table.html.erb

@@ -12,9 +12,9 @@
12 12
     </tr>
13 13
 
14 14
     <% @agents.each do |agent| %>
15
-      <tr class='<%= "agent-disabled" if agent.disabled? %>'>
16
-        <td>
17
-          <%= agent.name %>
15
+      <tr>
16
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
17
+          <%= link_to agent.name, agent_path(agent) %>
18 18
           <br/>
19 19
           <span class='text-muted'><%= agent.short_type.titleize %></span>
20 20
           <% if agent.scenarios.present? %>
@@ -23,35 +23,35 @@
23 23
             </span>
24 24
           <% end %>
25 25
         </td>
26
-        <td>
26
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
27 27
           <% if agent.can_be_scheduled? %>
28 28
             <%= agent.schedule.to_s.humanize.titleize %>
29 29
           <% else %>
30 30
             <span class='not-applicable'></span>
31 31
           <% end %>
32 32
         </td>
33
-        <td>
33
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
34 34
           <% if agent.can_be_scheduled? %>
35 35
             <%= agent.last_check_at ? time_ago_in_words(agent.last_check_at) + " ago" : "never" %>
36 36
           <% else %>
37 37
             <span class='not-applicable'></span>
38 38
           <% end %>
39 39
         </td>
40
-        <td>
40
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
41 41
           <% if agent.can_create_events? %>
42 42
             <%= agent.last_event_at ? time_ago_in_words(agent.last_event_at) + " ago" : "never" %>
43 43
           <% else %>
44 44
             <span class='not-applicable'></span>
45 45
           <% end %>
46 46
         </td>
47
-        <td>
47
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
48 48
           <% if agent.can_receive_events? %>
49 49
             <%= agent.last_receive_at ? time_ago_in_words(agent.last_receive_at) + " ago" : "never" %>
50 50
           <% else %>
51 51
             <span class='not-applicable'></span>
52 52
           <% end %>
53 53
         </td>
54
-        <td>
54
+        <td class='<%= "agent-disabled" if agent.disabled? %>'>
55 55
           <% if agent.can_create_events? %>
56 56
             <%= link_to(agent.events_count || 0, events_path(:agent => agent.to_param)) %>
57 57
           <% else %>
@@ -60,15 +60,11 @@
60 60
         </td>
61 61
         <td><%= working(agent) %></td>
62 62
         <td>
63
-          <div class="btn-group btn-group-xs">
64
-            <%= link_to 'Show', agent_path(agent), class: "btn btn-default" %>
65
-            <%= link_to 'Edit', edit_agent_path(agent), class: "btn btn-default" %>
66
-            <%= link_to 'Delete', agent_path(agent), method: :delete, data: { confirm: 'Are you sure you wish to permenantly delete this Agent?' }, class: "btn btn-default" %>
67
-            <% if agent.can_be_scheduled? && !agent.disabled? %>
68
-              <%= link_to 'Run', run_agent_path(agent, :return => "index"), method: :post, class: "btn btn-default" %>
69
-            <% else %>
70
-              <%= link_to 'Run', "#", class: "btn btn-default disabled" %>
71
-            <% end %>
63
+          <div class="btn-group">
64
+            <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
65
+              <span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span>
66
+            </button>
67
+            <%= render 'action_menu', :agent => agent, :returnTo => "index" %>
72 68
           </div>
73 69
         </td>
74 70
       </tr>
@@ -76,4 +72,4 @@
76 72
   </table>
77 73
 </div>
78 74
 
79
-<%= paginate @agents, :theme => 'twitter-bootstrap-3' %>
75
+<%= paginate @agents, :theme => 'twitter-bootstrap-3' %>

+ 7 - 32
app/views/agents/show.html.erb

@@ -2,6 +2,8 @@
2 2
   <div class='row'>
3 3
     <div class='col-md-2'>
4 4
         <ul class="nav nav-pills nav-stacked" id="show-tabs">
5
+          <li><%= link_to '<span class="glyphicon glyphicon-chevron-left"></span> Back'.html_safe, agents_path %></li>
6
+
5 7
           <% if agent_show_view(@agent).present? %>
6 8
             <li class='active'><a href="#summary" data-toggle="tab"><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
7 9
             <li><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
@@ -9,45 +11,18 @@
9 11
             <li class='disabled'><a><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
10 12
             <li class='active'><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
11 13
           <% end %>
14
+
12 15
           <li><a href="#logs" data-toggle="tab" data-agent-id="<%= @agent.id %>" class='<%= @agent.recent_error_logs? ? 'recent-errors' : '' %>'><span class='glyphicon glyphicon-list-alt'></span> Logs</a></li>
13 16
 
14 17
           <% if @agent.can_create_events? && @agent.events.count > 0 %>
15 18
             <li><%= link_to '<span class="glyphicon glyphicon-random"></span> Events'.html_safe, events_path(:agent => @agent.to_param) %></li>
19
+          <% else %>
20
+            <li class='disabled'><a><span class='glyphicon glyphicon-random'></span> Events</a></li>
16 21
           <% end %>
17
-          <li><%= link_to '<span class="glyphicon glyphicon-chevron-left"></span> Back'.html_safe, agents_path %></li>
18
-          <li><%= link_to '<span class="glyphicon glyphicon-pencil"></span> Edit'.html_safe, edit_agent_path(@agent) %></li>
19 22
 
20 23
           <li class="dropdown">
21
-            <a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
22
-            <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
23
-              <% if @agent.can_be_scheduled? %>
24
-                <li>
25
-                  <%= link_to '<span class="glyphicon glyphicon-refresh"></span> Run'.html_safe, run_agent_path(@agent, :return => "show"), method: :post, :tabindex => "-1" %>
26
-                </li>
27
-              <% end %>
28
-
29
-              <% if @agent.can_create_events? && @agent.events.count > 0 %>
30
-                <li>
31
-                  <%= link_to '<span class="glyphicon glyphicon-trash"></span> Delete all events'.html_safe, remove_events_agent_path(@agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL events for this Agent?'}, :tabindex => "-1" %>
32
-                </li>
33
-              <% end %>
34
-
35
-              <li>
36
-                <%= link_to '<span class="glyphicon glyphicon-plus"></span> Clone'.html_safe, new_agent_path(id: @agent), :tabindex => "-1" %>
37
-              </li>
38
-
39
-              <li>
40
-                <% if @agent.disabled? %>
41
-                  <%= link_to '<i class="glyphicon glyphicon-play"></i> Enable agent'.html_safe, agent_path(@agent, :agent => { :disabled => false }, :return => "show"), :method => :put %>
42
-                <% else %>
43
-                  <%= link_to '<i class="glyphicon glyphicon-pause"></i> Disable agent'.html_safe, agent_path(@agent, :agent => { :disabled => true }, :return => "show"), :method => :put %>
44
-                <% end %>
45
-              </li>
46
-
47
-              <li>
48
-                <%= link_to '<span class="glyphicon glyphicon-remove"></span> Delete'.html_safe, agent_path(@agent), method: :delete, data: { confirm: 'Are you sure you wish to permenantly delete this Agent?' }, :tabindex => "-1" %>
49
-              </li>
50
-            </ul>
24
+            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span></a>
25
+            <%= render 'action_menu', :agent => @agent, :returnTo => "show" %>
51 26
           </li>
52 27
         </ul>
53 28
       </div>